package com.ruoyi.recommd.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.recommd.domain.Luodiye;
import com.ruoyi.recommd.service.ILuodiyeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 落地页Controller
 * 
 * @author ruoyi
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/recommd/luodiye")
public class LuodiyeController extends BaseController
{
    @Autowired
    private ILuodiyeService luodiyeService;

    /**
     * 查询落地页列表
     */
    @PreAuthorize("@ss.hasPermi('recommd:luodiye:list')")
    @GetMapping("/list")
    public TableDataInfo list(Luodiye luodiye)
    {
        startPage();
        List<Luodiye> list = luodiyeService.selectLuodiyeList(luodiye);
        return getDataTable(list);
    }

    /**
     * 导出落地页列表
     */
    @PreAuthorize("@ss.hasPermi('recommd:luodiye:export')")
    @Log(title = "落地页", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Luodiye luodiye)
    {
        List<Luodiye> list = luodiyeService.selectLuodiyeList(luodiye);
        ExcelUtil<Luodiye> util = new ExcelUtil<Luodiye>(Luodiye.class);
        util.exportExcel(response, list, "落地页数据");
    }

    /**
     * 获取落地页详细信息
     */
    //@PreAuthorize("@ss.hasPermi('recommd:luodiye:query')")
    //@GetMapping(value = "/{id}")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(luodiyeService.selectLuodiyeById(id));
    }

    @RequestMapping(value = "/getLuodiyeById/{id}")
    public AjaxResult getLuodiyeById(@PathVariable("id") Long id)
    {
        return success(luodiyeService.selectLuodiyeById(id));
    }

    /**
     * 新增落地页
     */
    @PreAuthorize("@ss.hasPermi('recommd:luodiye:add')")
    @Log(title = "落地页", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Luodiye luodiye)
    {
        return toAjax(luodiyeService.insertLuodiye(luodiye));
    }

    /**
     * 修改落地页
     */
    @PreAuthorize("@ss.hasPermi('recommd:luodiye:edit')")
    @Log(title = "落地页", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Luodiye luodiye)
    {
        return toAjax(luodiyeService.updateLuodiye(luodiye));
    }

    /**
     * 删除落地页
     */
    @PreAuthorize("@ss.hasPermi('recommd:luodiye:remove')")
    @Log(title = "落地页", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(luodiyeService.deleteLuodiyeByIds(ids));
    }
}
